﻿/// <reference path="../Ext4.0/ext-all.js" />


var RoleTypeStore = Ext.create('Ext.data.Store', {
    remoteSort: true,
    fields: ['value', 'name'],
    proxy: {
        type: 'ajax',
        url: "UserMag.aspx?action=BindRoleType",
        actionMethods: 'post',
        reader: {
            type: 'json',
            root: 'data'
        }
    }
})

RoleTypeStore.load();
var TemplateStore = Ext.create('Ext.data.Store', {
    remoteSort: true,
    fields: ['value', 'name'],
    proxy: {
        type: 'ajax',
        url: "UserMag.aspx?action=BindTemplate",
        actionMethods: 'post',
        reader: {
            type: 'json',
            root: 'data'
        }
    }
})

TemplateStore.load();
var AddInfoForm = Ext.create('Ext.form.Panel', {
    id: "frmAdd",
    width: 350,
    height: 350,
    plain: true,
    frame: true,
    labelWidth: 45,
    defaultType: "textfield",
    baseCls: "x-plain",
    layout: 'anchor',
    defaults: { anchor: "95%", msgTarget: "side" },
    url: "UserMag.aspx?action=Add",

    defaultType: 'textfield',
    items: [{
        fieldLabel: '姓名',
        name: 'Name',
        allowBlank: false,
        blankText: "考生姓名不能为空"
    }, {
        fieldLabel: '手机号码',
        name: 'Tel',
        allowBlank: false,
        blankText: "联系电话不能为空，将作为考生登录账号"
    }, {
        xtype: 'radiogroup',
        fieldLabel: '性别',
        items: [
                { boxLabel: '男', name: 'Gender', inputValue: "男", checked: true },
                { boxLabel: '女', name: 'Gender', inputValue: "女" }
            ]
    }, {
        fieldLabel: '学校',
        name: 'School',
        allowBlank: true
    }, {
        fieldLabel: '报考学校',
        name: 'ExamSchool',
        allowBlank: true
    }, {
        name: "Template",
        xtype: 'combobox',
        fieldLabel: '考试类型',
        store: TemplateStore,
        valueField: 'value',
        allowBlank: false,
        displayField: 'name',
        triggerAction: "all"
    }, {
        fieldLabel: '报名序号',
        name: 'Sequence',
        allowBlank: true
    }, {
        fieldLabel: '业务员ID',
        name: 'EmployeeID',
        hidden: true
    }, {
        name: "EmployeeName",
        fieldLabel: "业务员",
        allowBlank: true,
        value: EmployeeName,
        listeners: {
            'focus': function () {
                Employee();
            }
        }

    }, {
        fieldLabel: '备注',
        name: 'Bak',
        allowBlank: true
    }, {
        fieldLabel: '意向同住人',
        name: 'ExceptRoomie',
        allowBlank: true
    }],

    buttonAlign: "center",
    bodyStyle: "padding:0 0 0 0",
    buttons: [{
        text: '新增',
        formBind: true,
        disabled: true,
        handler: function () {

            var form = Ext.getCmp('frmAdd').getForm();
            if (form.isValid()) {
                form.submit({
                    success: function (form, action) {
                        Ext.Msg.alert("恭喜", "新增成功");
                        StorePage.load();
                   
                        OrgName = "";
                        addWin.hide();
                    },
                    failure: function (form, action) {
                        Ext.Msg.alert('Failed', action.result.msg);
                    }
                });
            }
        }
    }]
});
var addWin = Ext.create('Ext.window.Window', {
    title: '新增账号',
    width: 350,
    height: 370,
    layout: 'fit',
    labelWidth: 100,
    closeAction: 'hide',
    resizable: false,
    modal: 'true',
    iconCls: "addicon",
    items: AddInfoForm,
    listeners: {
            "show": function () {
                AddInfoForm.getForm().reset();
            }
    }
});

